package com.youhome.common.enums;

/**
 * Created by chen365 on 2019/02/18.
 */
public enum HouseDataSourceEnum {
    ListHub(1, "ListHub"),
    SimplyRETS(2, "SimplyRETS"),
    YouHome(3, "YouHome");

    //1->ListHub;2->SimplyRETS;3->YouHome

    private Integer key;
    private String name;

    HouseDataSourceEnum(Integer key, String name) {
        this.key = key;
        this.name = name;
    }

    //根据key获取枚举
    public static HouseDataSourceEnum getEnumByKey(Integer key) {
        if (null == key) {
            return null;
        }
        for (HouseDataSourceEnum temp : HouseDataSourceEnum.values()) {
            if (temp.getKey().equals(key)) {
                return temp;
            }
        }
        return null;
    }

    //根据key获取枚举
    public static HouseDataSourceEnum getEnumByName(String name) {
        if (null == name) {
            return null;
        }
        for (HouseDataSourceEnum temp : HouseDataSourceEnum.values()) {
            if (temp.getName().equals(name)) {
                return temp;
            }
        }
        return null;
    }

    public Integer getKey() {
        return key;
    }

    public void setKey(Integer key) {
        this.key = key;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
